package com.uenpay.im.ui.old.activity.transfer;

import com.qiyunxin.android.http.net.HttpInvokeItem;
import com.uenpay.im.configuration.APIConfiguration;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * 转账
 * 
 * @author SL
 * @copyRight http://www.qiyunxin.com
 */
public class TransferInvokItem extends HttpInvokeItem {

	public class TransferInvokItemResult {
		public int status;
		public String msg;
	}

	public TransferInvokItemResult getOutput() {
		return (TransferInvokItemResult) GetResultObject();
	}

	/**
	 * 转账
	 * @param custid
	 * @param amount
	 * @param targettotal
	 * @param paypassword
	 */
	public TransferInvokItem(String custid, String amount, String targettotal,
			String paypassword,String memo) {
		String url = APIConfiguration.getBaseUrl()
				+ "/Purse/Purse/transfer?amount=" + amount + "&custid="
				+ custid + "&memo="+memo+"&targettotal=" + targettotal + "&paypassword="
				+ paypassword + "&" + APIConfiguration.getCustIdAndToken();
		SetUrl(url);
	}

	@Override
	protected Object DeserializeResult(String responseBody) throws Exception {
		TransferInvokItemResult result = new TransferInvokItemResult();
		try {
			JSONObject json = new JSONObject(responseBody);
			result.status = json.optInt("status");
			result.msg = json.optString("msg");

		} catch (JSONException e) {
			e.printStackTrace();
			return result;
		}
		return result;
	}

}
